home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: TableFormatting
- Sub-category: AlternatingCols
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This XSLT file will display rows of data in an HTML table,
- displaying every alternate column in a different color.
- ================================================================ -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="html"/>
- <xsl:template match="/">
-
- <STYLE>
- H1: {COLOR: blue FONT-FAMILY: Arial; }
- SubTotal {COLOR: green; FONT-FAMILY: Arial}
- BODY {COLOR: blue; FONT-FAMILY: Arial; FONT-SIZE: 8pt;}
- TD.clsOdd { background-color: beige; }
- TD.clsEven { background-color: #cccccc; }
- </STYLE>
-
- <H2>Customer Listing (in Alternating colors) </H2>
- <table border="1" cellPadding="2" cellSpacing="1">
- <tr borderColorDark="#fcfcfc" borderColorLight="#999999">
- <xsl:for-each select="//customers/customer[1]/@*">
- <th>
- <xsl:value-of select="name()"/>
- </th>
- </xsl:for-each>
- </tr>
- <xsl:for-each select="/customers/customer">
- <tr>
- <xsl:for-each select="@*">
- <td>
- <xsl:choose>
- <xsl:when test="position() mod 2 = 1">
- <xsl:attribute name="class">clsOdd</xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="class">clsEven</xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="."/>
- </td>
- </xsl:for-each>
- </tr>
- </xsl:for-each>
- </table>
- <H3>Total Customers <xsl:value-of select="count(customers/customer)"/>
- </H3>
- </xsl:template>
- </xsl:stylesheet>